// // middleware.ts (根目录)
import { NextRequest, NextResponse } from "next/server";

export function middleware(request: NextRequest) {
  console.log("request: ", request.nextUrl.pathname);
  if (request.nextUrl.pathname.startsWith("/api")) {
  }
  // const token = request.headers.get("Authorization");
  // if (!token) {
  //   return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  // }
  return NextResponse.next();
}

// import { verify } from "jsonwebtoken";
// import { NextResponse, NextRequest } from "next/server";

// export async function middleware(req: NextRequest) {
//   const token = req.cookies.get("auth")?.value;
//   const url = req.nextUrl.clone();

//   if (!token && !req.nextUrl.pathname.startsWith("/login")) {
//     url.pathname = "/login";
//     return NextResponse.redirect(url);
//   }

//   try {
//     verify(token, process.env.JWT_SECRET);
//     return NextResponse.next();
//     // eslint-disable-next-line @typescript-eslint/no-unused-vars
//   } catch (e) {
//     url.pathname = "/login";
//     return NextResponse.redirect(url);
//   }
// }
